Tutorial: Sharing Anchors
Introduction
Sharing anchors between devices is essential for multi-user AR experiences. This tutorial will guide you through the process of sharing anchors by using Photon to transmit anchor UUIDs in real-time and cloud storage to persistently store the anchor data.
At a high level, the process works as follows:
- When a user creates an anchor, its UUID is sent to other users in the same Photon room.
- The anchor data is then stored in a cloud storage solution.
- Other users in the room, upon receiving the UUID, access the cloud storage to download the anchor data.
- Once downloaded, the anchor is loaded into their AR scene, effectively sharing the anchor across devices.
For the cloud storage part, any cloud storage provider that allows file upload and download can be used. In this tutorial, we provide examples for two cloud storage solutions:
- Firebase
- Alibaba Cloud OSS.
The methods for other providers should be similar, and developers are encouraged to explore the options that best suit their needs.
You can find the complete code in this Git repository.
Prerequisites
- Unity with NRSDK 2.1 or later installed.
- Photon Unity Networking 2 (PUN 2) package.
- Firebase Unity SDK.
All Materials Needed in This Tutorial
The following package includes all the necessary scene and the majority of the scripts required for this tutorial. However, it's important to note that developers will still need to complete the steps related to photon and cloud storage themselves.
Additionally, due to the tutorial's involvement with modifications to the built-in scripts of NRSDK, specifically NRWorldAnchor.cs and NRWorldAnchorStore.cs, these changes cannot be included within this package. Please refer to the tutorial's content, specifically in the section on 'Implementing Cloud Save and Load,' to make the necessary modifications.